package com.example.laundry.dto;

import com.example.laundry.entity.LaundryOrderEntity;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class LaundryOrderDto {
    private Long id;
    private Long userId;
    private String orderNumber;
    private String customerName;
    private String customerPhone;
    private String pickupAddress;
    private String deliveryAddress;
    private BigDecimal totalAmount;
    private LaundryOrderEntity.OrderStatus status;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private List<LaundryItemDto> items;
    private List<OrderStatusHistoryDto> statusHistory;

    public static LaundryOrderDto fromEntity(LaundryOrderEntity entity) {
        LaundryOrderDto dto = new LaundryOrderDto();
        dto.setId(entity.getId());
        dto.setUserId(entity.getUser().getId());
        dto.setOrderNumber(entity.getOrderNumber());
        dto.setCustomerName(entity.getCustomerName());
        dto.setCustomerPhone(entity.getCustomerPhone());
        dto.setPickupAddress(entity.getPickupAddress());
        dto.setDeliveryAddress(entity.getDeliveryAddress());
        dto.setTotalAmount(entity.getTotalAmount());
        dto.setStatus(entity.getStatus());
        dto.setCreatedAt(entity.getCreatedAt());
        dto.setUpdatedAt(entity.getUpdatedAt());
        return dto;
    }
}